package net.chasing.androidbaseconfig.widget.view_pager;

import android.content.Context;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.view.View;

/**
 * 通过canScroll进行控制能否左右滑动
 */
public class MyViewPager extends ViewPager {
    private boolean canScroll = true;

    public MyViewPager(Context context) {
        super(context);
    }

    public MyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setCanScroll(boolean canScroll) {
        this.canScroll = canScroll;
    }

    @Override
    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
        if(!canScroll) {
            return true;
        }
        return super.canScroll(v,checkV,dx,x,y);
    }
}